using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace ModWatch
{

	/// <summary>
	/// Provides a collection of <see cref="ModWatch.IModWatcher"/> objects.
	/// </summary>
	public sealed class ModWatcherCollection : IEnumerable<IModWatcher>
	{

		/// <summary>
		/// The <see cref="ModWatch.IModWatcher"/> objects contained
		/// in this collection.
		/// </summary>
		private List<IModWatcher> _modWatchers = null;

		/// <summary>
		/// Initializes a new instance of the <see cref="ModWatcherCollection"/> class.
		/// </summary>
		public ModWatcherCollection()
		{
			_modWatchers = new List<IModWatcher>();
		}

		/// <summary>
		/// Adds a <see cref="ModWatch.IModWatcher"/> to the end of the collection.
		/// </summary>
		/// <param name="ModWatcher">
		/// The <see cref="ModWatch.IModWatcher"/> to be added.
		/// </param>
		public void Add(IModWatcher ModWatcher)
		{
			this._modWatchers.Add(ModWatcher);
		}

		/// <summary>
		/// Determines whether an element is in the collection.
		/// </summary>
		/// <param name="ModWatcher">
		/// The <see cref="ModWatch.IModWatcher"/> being searched for.
		/// </param>
		/// <returns>
		/// true if the collection contains the
		/// <see cref="ModWatch.IModWatcher"/>, false otherwise.
		/// </returns>
		public bool Contains(IModWatcher ModWatcher)
		{
			return this._modWatchers.Contains(ModWatcher);
		}

		/// <summary>
		/// Returns an enumerator that iterates through the
		/// <see cref="ModWatch.IModWatcher"/> objects.
		/// </summary>
		/// <returns>
		/// The enumerator of <see cref="ModWatch.IModWatcher"/> objects.
		/// </returns>
		public IEnumerator<IModWatcher> GetEnumerator()
		{
			return this._modWatchers.GetEnumerator();
		}

		/// <summary>
		/// Returns an enumerator that iterates through the
		/// <see cref="ModWatch.IModWatcher"/> objects.
		/// </summary>
		/// <returns>
		/// The enumerator of <see cref="ModWatch.IModWatcher"/> objects.
		/// </returns>
		IEnumerator IEnumerable.GetEnumerator()
		{
			return this.GetEnumerator();
		}

		/// <summary>
		/// Removes the first occurence of a specified
		/// <see cref="ModWatch.IModWatcher"/> from the collection.
		/// </summary>
		/// <param name="ModWatcher">
		/// The <see cref="ModWatch.IModWatcher"/> to be removed.
		/// </param>
		public void Remove(IModWatcher ModWatcher)
		{
			this._modWatchers.Remove(ModWatcher);
		}

		/// <summary>
		/// Gets the number of <see cref="ModWatch.IModWatcher"/>
		/// objects contained in the collection.
		/// </summary>
		public int Count
		{
			get { return this._modWatchers.Count; }
		}

		/// <summary>
		/// Gets the <see cref="ModWatch.IModWatcher"/>
		/// element at the specified index.
		/// </summary>
		/// <param name="index">The zero based element to get.</param>
		/// <returns>
		/// The <see cref="ModWatch.IModWatcher"/> object
		/// located at the specified index.
		/// </returns>
		public IModWatcher this[int index]
		{
			get { return this._modWatchers[index]; }
		}

	}

}
